<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <h3>登录页面</h3>
  <input type="text" id="uname">
  <button id='btn'>确认登录</button>
  <script src="./js/socket.io.min.js"></script>
  <script>
    const client = io.connect('/')
    client.emit('uname', 'admin')

    // 发送
    document.querySelector('#btn').onclick = function () {
      let uname = document.querySelector('#uname').value.trim()
      client.emit('login', uname)
    }
  </script>
</body>

</html>